(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('cda.ppfProgram.viewController', viewController);
	viewController.$inject = [ '$scope', 'Constants', 'layoutConfig', 'validatorConfig', 'gridService', 'authService', 'ppfProgramService', '$filter' ];
	function viewController($scope, Constants, layoutConfig, validatorConfig, gridService, authService, ppfProgramService, $filter) {
		var ctrl = this, ppfProgramInfo = $scope.$stateParams.params;
		//ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		ctrl.ppfProgram = {};

		ctrl.init = function() {
			var params = {
					programId : ppfProgramInfo.programId
			};
			// init acct
			ppfProgramService.initProfAcct(layoutConfig, $scope, ctrl);
			// init int
			//ppfProgramService.initProfInt(layoutConfig, $scope, ctrl);
			//ppfProgramService.initProfCostOfFundInt(layoutConfig, $scope, ctrl);
			// init pastdue
			ppfProgramService.initProfPastdue(layoutConfig, $scope, ctrl);
			// init fee
			ppfProgramService.initProfFee(layoutConfig, $scope, ctrl);
			// init doc
			ppfProgramService.initEventDoccfg(layoutConfig, $scope, ctrl);
			// init limit facility
			//ppfProgramService.initProfLimitFaci(layoutConfig, $scope, ctrl);
			//ppfProgramService.initProfLimitInsFaci(layoutConfig, $scope, ctrl);
			//ppfProgramService.initProfLimitPurFaci(layoutConfig, $scope, ctrl);
			// init Settlement Instruction
			ppfProgramService.initProfSetlinst(layoutConfig, $scope, ctrl);
			// init cust prop define
			ppfProgramService.initCustProp(layoutConfig, $scope, ctrl);
			//
			ppfProgramService.initGeneral($scope, ctrl).then(function() {
				authService.view(params).then(function(response) {
					var initPpfProgram = response.data || ppfProgramInfo;
					ctrl.action = "view";
					ppfProgramService.initLayoutConfigAndModel($scope, ctrl, initPpfProgram, ctrl.action, false).then(function() {
					});
				});
			});
		};
		
	}
})(angular);